package org.come.until;

import java.awt.Color;
import java.awt.Graphics;
import java.math.BigDecimal;
import java.util.*;

import javax.swing.ImageIcon;

import org.apache.commons.lang.StringUtils;
import org.come.Frame.PawnJfram;
import org.come.Frame.AlchemyJframe;
import org.come.Frame.BoothBoxJframe;
import org.come.Frame.CollectionJadeJframe;
import org.come.Frame.ExchangeValueJframe;
import org.come.Frame.ForgeJframe;
import org.come.Frame.GiveJframe;
import org.come.Frame.PetEquipmentJframe;
import org.come.Frame.RuneOperateJframe;
import org.come.Frame.TestpackJframe;
import org.come.Frame.TradeJframe;
import org.come.Frame.TransJframe;
import org.come.Frame.WorkshopRefiningJframe;
import org.come.Frame.ZhuFrame;
import org.come.Jpanel.GemRefineryMainJpanel;
import org.come.Jpanel.TestpackJapnel;
import org.come.Jpanel.TransJpanel;
import org.come.Jpanel.WorkshopRefiningCardJpanel;
import org.come.MountShouHu.ShouhuPackJframe;
import org.come.baitan.BaiTanJframe;
import org.come.bean.ConfigureBean;
import org.come.bean.GoodTrans;
import org.come.bean.IncludedPart;
import org.come.bean.PathPoint;
import org.come.entity.Goodstable;
import org.come.entity.PackRecord;
import org.come.entity.RoleSummoning;
import org.come.model.Configure;
import org.come.model.InternalForm;
import org.come.mouslisten.GoodsMouslisten;
import org.come.socket.Agreement;
import org.come.socket.SendMessageUntil;
import org.come.starcard.BtnStarCard;
import org.come.starcard.JframeStarCardMain;
import org.come.starcard.JframeStarTransferMain;
import org.come.starcard.JpanelStarCardMain;
import org.come.starcard.JpanelStarTransferMain;
import org.come.summonequip.JframeSummonEquipMain;
import org.come.summonequip.JpanelSummonEquipMain;
import org.wing.panel.LHMainPanel;
import org.wing.panel.WingMainFrame;
import org.wing.panel.WingMainPanel;

import com.tool.Stall.Commodity;
import com.tool.Stall.Stall;
import com.tool.Stall.StallBean;
import com.tool.btn.BaptizeBtn;
import com.tool.btn.goodbtn;
import com.tool.image.ImageMixDeal;
import com.tool.role.RoleData;
import com.tool.role.RoleProperty;
import com.tool.tcpimg.UIUtils;
import com.tool.time.TimeLimit;

/**
 * @author 黄建彬
 * @date : 2017年12月4日 下午2:51:23
 *
 *       此类用来保存数据库发送的物品装备信息，方便使用和对数据操作后返还给服务器警醒修改
 */
public class GoodsListFromServerUntil {
    private static Goodstable[] Goodslist = new Goodstable[24];// 背包物品的信息list
    public static Goodstable[] choseGoodsList = new Goodstable[14];// 穿上的物品集合下标13星卡
    private static List<Goodstable> wingGoodsList = new ArrayList<>(); // 翅膀物品集合
    private static List<Goodstable> starCardList = new ArrayList<>(); // 星卡物品集合
    private static ImageIcon[] goodimg = new ImageIcon[24];// 存放当前背包页面的img
    public static ImageIcon lockimg = new ImageIcon("inkImg/hongmu/2/goodorpet_lock.png");
    public static int NB = 0;
    public static ImageIcon imageIcon=new ImageIcon("inkImg/btsg/4935-1.png");//摆摊后物品显示的已上架图标
    public static void draw(Graphics g, int x, int y) {
    		g.setFont(UIUtils.TEXT_FONT);
            g.setColor(Color.red);
            for (int i = 0; i < 24; i++) {
                int row = i % 6 * 51;
                int col = i / 6 * 51;
                if (Goodslist[i + Pagenumber * 24] != null) {
                    if (goodimg[i] != null) {
                        g.drawImage(goodimg[i].getImage(), x + row + 2, y + col + 2, 45, 45, null);
                    }
                    if (!EquipTool.isEquip(Goodslist[i + Pagenumber * 24].getType())) {
                        g.drawString(Goodslist[i + Pagenumber * 24].getUsetime() + "", x + 4 + row, y + 10 + col);
                    }
                    // 判断如果是已加锁，则加上加锁标志
                    if (Goodslist[i + Pagenumber * 24].getGoodlock() == 1) {
                        g.drawImage(lockimg.getImage(), x + row + 38, y + col + 2, 10, 12, null);
                    }
                    if (BaiTanJframe.getBaiTanJframe().getBaiTanJpanel().goodstableList.containsKey(GoodsListFromServerUntil.Goodslist[i + GoodsListFromServerUntil.Pagenumber * 24]))
                        g.drawImage(imageIcon.getImage(), x + row + 2, y + col + 2+10, 50, 20, null);
                }
            }


    }

    // 绘制装备和加锁状态
    public static void drawLock(Graphics g, TestpackJapnel testpackJapnel) {
    	ConfigureBean allConfigure = UserMessUntil.getConfigureBean();
    	Map<BigDecimal, Configure> item = allConfigure.getAllConfigure();
    	Configure configure = item.get(new BigDecimal(1));
    	int szz = 5;//3种族
    	if(configure.getLzjskg()!=null) {
    		szz = Integer.parseInt(configure.getLzjskg());
    	}
    	if(szz == 3) {
        		g.setColor(UIUtils.COLOR_Pack);
                for (int i = 0; i < 12; i++) {
                    PathPoint path = testpackJapnel.path(i);
                    int row = path.getX();
                    int col = path.getY();
                    if (choseGoodsList[i] != null) {
                        g.fillRect(row, col, 49, 49);
                        if(i == 3) {
                        	g.drawImage(imgpath(choseGoodsList[i].getSkin()).getImage(), row + 2, col + 2, 45, 45, null);
                        }else if(i == 0) {
                            g.fillRect(row, col, 95, 95);
                        	g.drawImage(imgpath(choseGoodsList[i].getSkin()).getImage(), row + 2, col + 2, 95, 95, null);
                        }else if(i == 5) {
                        	g.drawImage(imgpath(choseGoodsList[i].getSkin()).getImage(), row + 2, col + 2, 45, 45, null);
                        }else if(i == 2) {
                        	g.drawImage(imgpath(choseGoodsList[i].getSkin()).getImage(), row + 2, col + 2, 45, 45, null);
                        }else {
                        	g.drawImage(imgpath(choseGoodsList[i].getSkin()).getImage(), row + 2, col + 2, 45, 45, null);
                        }
                        // 判断如果是已加锁，则加上加锁标志
                        if (choseGoodsList[i].getGoodlock() == 1) {
                            g.drawImage(lockimg.getImage(), row + 38, col + 2, 10, 12, null);
                        }
                    }
                }

    	}else {
        		g.setColor(UIUtils.COLOR_Pack);
                for (int i = 0; i < 12; i++) {
                    PathPoint path = testpackJapnel.path(i);
                    int row = path.getX();
                    int col = path.getY();
                    if (choseGoodsList[i] != null) {
                        g.fillRect(row, col, 49, 49);
                        g.drawImage(imgpath(choseGoodsList[i].getSkin()).getImage(), row + 2, col + 2, 45, 45, null);
                        // 判断如果是已加锁，则加上加锁标志
                        if (choseGoodsList[i].getGoodlock() == 1) {
                            g.drawImage(lockimg.getImage(), row + 38, col + 2, 10, 12, null);
                        }
                    }
                }

    	}
    }

    // 绘制人物身上未装备、且不是套装的装备
    public static void drawIdlEqu(Graphics g, int x, int y, int page, int number, int para) {
    		if (AccessSuitMsgUntil.accessIdlEqu(1) != null && AccessSuitMsgUntil.accessIdlEqu(1).size() > 0) {
                int size = (AccessSuitMsgUntil.accessIdlEqu(1).size() / number + (AccessSuitMsgUntil.accessIdlEqu(1).size()
                        % number == 0 ? 0 : 1))
                        * number;
                Goodstable[] Goodslist = new Goodstable[size];
                for (int i = 0; i < AccessSuitMsgUntil.accessIdlEqu(1).size(); i++) {
                    Goodslist[i] = AccessSuitMsgUntil.accessIdlEqu(1).get(i);
                }
                for (int i = 0; i < number; i++) {
                    int row = i % para * 51;
                    int col = i / para * 51;
                    if (Goodslist[i + page * number] != null) {
                        g.drawImage(imgpath(Goodslist[i + page * number].getSkin()).getImage(), x + row + 2, y + col + 2,
                                45, 45, null);
                        if (Goodslist[i + page * number].getGoodlock() == 1) {
                            g.drawImage(lockimg.getImage(), x + row + 38, y + col + 2, 10, 12, null);
                        }
                    }
                }
            }

    }
    public static void shouhu(final int rig){
        int i=0;
        while (i<GoodsListFromServerUntil.Goodslist.length){
            if (GoodsListFromServerUntil.Goodslist[i]!=null&&GoodsListFromServerUntil.Goodslist[i].getRgid().intValue()==rig){
                GoodsListFromServerUntil.Goodslist[i]=null;
                return;
            }else i++;
        }
    }
    // 绘制人物身上的套装
    public static void drawRoleSuit(Graphics g, int x, int y, int page, int number) {
    		if (AccessSuitMsgUntil.accessIdlEqu(2) != null && AccessSuitMsgUntil.accessIdlEqu(2).size() > 0) {
                int size = (AccessSuitMsgUntil.accessIdlEqu(2).size() / number + (AccessSuitMsgUntil.accessIdlEqu(2).size()
                        % number == 0 ? 0 : 1))
                        * number;
                Goodstable[] Goodslist = new Goodstable[size];
                for (int i = 0; i < AccessSuitMsgUntil.accessIdlEqu(2).size(); i++) {
                    Goodslist[i] = AccessSuitMsgUntil.accessIdlEqu(2).get(i);
                }
                for (int i = 0; i < number; i++) {
                    int row = i % 3 * 51;
                    int col = i / 3 * 51;
                    if (Goodslist[i + page * number] != null) {
                        g.drawImage(imgpath(Goodslist[i + page * number].getSkin()).getImage(), x + row + 2, y + col + 2,45, 45, null);
                        if (Goodslist[i + page * number].getGoodlock() == 1) {
                            g.drawImage(lockimg.getImage(), x + row + 38, y + col + 2, 10, 12, null);
                        }
                    }
                }
            }

    }

    // 绘制已收录的套装部件
    public static void drawIncludedSuit(Graphics g, int x, int y, int suitid) {
    		g.setFont(UIUtils.TEXT_FONT);
            g.setColor(Color.white);
            if (suitid <= 0) {
                return;
            }
            // 获取已收录套装的信息
            List<IncludedPart> parts = AccessSuitMsgUntil.getIncludedMsg(suitid);
            for (int i = 0; i < parts.size(); i++) {
                if (i > 3) {
                    g.drawImage(imgpath("tz" + suitid + "_" + parts.get(i).getPartid()).getImage(), x + 15 + (i - 4) * 67, y + 71, 50, 50, null);
                    g.drawString(parts.get(i).getNumber() + "", x + 15 + (i - 4) * 67, y + 81);
                } else {
                    g.drawImage(imgpath("tz" + suitid + "_" + parts.get(i).getPartid()).getImage(), x + 2 + i * 67, y, 50, 50, null);
                    g.drawString(parts.get(i).getNumber() + "", x + 3 + i * 67, y + 10);
                }
            }

    }

    // 绘制背包身上的宝石
    public static void drawGemstoneOperationSuit(Graphics g, int number) {
    		g.setFont(UIUtils.TEXT_FONT);
            g.setColor(Color.red);
            for (int i = 0; i < Goodslist.length; i++) {
                if (Goodslist[i] != null) {
                    if (!Goodtype.BS(Goodslist[i].getType())) {
                        continue;
                    }
                    g.drawImage(CutButtonImage.getGemstoneIcon(Goodslist[i].getSkin(), 51, 51).getImage(),
                            50 + number % 6 * 51, 308 + number / 6 * 51, 48, 48, null);
                    if (!EquipTool.isEquip(Goodslist[i].getType())) {
                        g.drawString(Goodslist[i].getUsetime() + "", 54 + number % 6 * 51, 318 + number / 6 * 51);
                    }
                    // 判断如果是已加锁，则加上加锁标志
                    if (Goodslist[i].getGoodlock() == 1) {
                        g.drawImage(lockimg.getImage(), 88 + number % 6 * 51, number / 6 * 51 + 310, 10, 12, null);
                    }
                    number++;
                    if (number >= 12) {
                        return;
                    }
                }
            }

    }

    public static Goodstable getGemstoneOperationSuit(int p, int number) {
        for (int i = 0; i < Goodslist.length; i++) {
            if (Goodslist[i] != null) {
                if (!Goodtype.BS(Goodslist[i].getType())) {
                    continue;
                }
                if (number == p) {
                    return Goodslist[i];
                }
                number++;
            }
        }
        return null;
    }

    // 绘制背包身上的宝石
    public static void drawGemstoneSuit(Graphics g, int number, int type) {
    		g.setFont(UIUtils.TEXT_FONT);
            g.setColor(Color.red);
            int num = 0;
            for (int i = 0; i < Goodslist.length; i++) {
                if (Goodslist[i] != null) {
                    if (!Goodtype.baoshi(type, Goodslist[i].getType())) {
                        continue;
                    }
                    g.drawImage(CutButtonImage.getGemstoneIcon(Goodslist[i].getSkin(), 48, 48).getImage(),
                            224 + 23 + num * 51, 284, 48, 48, null);
                    if (!EquipTool.isEquip(Goodslist[i].getType())) {
                        g.drawString(Goodslist[i].getUsetime() + "", 228 + 23 + num * 51, 284);
                    }
                    // 判断如果是已加锁，则加上加锁标志
                    if (Goodslist[i].getGoodlock() == 1) {
                        g.drawImage(lockimg.getImage(), 272 + 23 + num * 51, 284, 10, 12, null);
                    }
                    num++;
                    if (num >= number) {
                        return;
                    }
                }
            }

    }

    public static Goodstable getGemstoneSuit(int p, int number, int type) {
        for (int i = 0; i < Goodslist.length; i++) {
            if (Goodslist[i] != null) {
                if (!Goodtype.baoshi(type, Goodslist[i].getType())) {
                    continue;
                }
                if (number == p) {
                    return Goodslist[i];
                }
                number++;
            }
        }
        return null;
    }

    // 绘制藏宝阁可出售物品-我要卖物品格子调整
    public static void drawCBG(Graphics g, int x, int y, int ys) {
    		ys = -ys * 40 - 1;
            for (int i = 0; i < Goodslist.length; i++) {
                Goodstable good = Goodslist[i];
                if (good == null || good.getGoodlock() == 1 || AnalysisString.jiaoyi(good.getQuality())
                        || !EquipTool.isEquip(good.getType())) {
                    continue;
                }
                if (Goodtype.EquipmentType(good.getType()) != -1
                        && AccessSuitMsgUntil.getExtra(good.getValue(), "套装属性") != null) {
                    continue;
                }
                ys++;
                if (ys >= 0) {
                    g.drawImage(imgpath(good.getSkin()).getImage(), x + ys % 8 * 48, y + ys / 8 * 48, 45, 45, null);
                    if (ys >= 39) {
                        return;
                    }
                }
            }

    }

    public static Goodstable getCBG(int ys, int p) {
    		p += ys * 40;
            ys = -ys * 40 - 1;
            for (int i = 0; i < Goodslist.length; i++) {
                Goodstable good = Goodslist[i];
                if (good == null || !EquipTool.isEquip(good.getType())) {
                    continue;
                }
                if (isJY(good)) {
                    continue;
                }
                ys++;
                if (p == ys) {
                    return good;
                }
            }

        return null;
    }

    public static Goodstable czGBG(BigDecimal rgid) {
        for (int i = 0; i < Goodslist.length; i++) {
            Goodstable good = Goodslist[i];
            if (good == null || !EquipTool.isEquip(good.getType())) {
                continue;
            }
            if (isJY(good)) {
                continue;
            }
            if (good.getRgid().compareTo(rgid) == 0) {
                return good;
            }
        }
        return null;
    }

    // 绘制召唤兽加锁状态
    public static void drawPetLock(Graphics g, RoleSummoning roleSummoning) {
    		g.drawImage(lockimg.getImage(), 338, 48, 10, 12, null);

    }

    public static int Pagenumber = 0;// 页数 0表示第一页
    // 已装备的符石
    public static Map<BigDecimal, Goodstable> fushis = new HashMap<BigDecimal, Goodstable>();
    public static Map<BigDecimal, Map<String, Object>> fushisAll = new HashMap<BigDecimal, Map<String, Object>>();

    /**
     * 根据表id找到goodstable
     *
     * @return
     */
    public static Goodstable czgood(BigDecimal rgid) {
        for (int i = 0; i < Goodslist.length; i++) {
            if (Goodslist[i] != null && rgid.compareTo(Goodslist[i].getRgid()) == 0) {
                return Goodslist[i];
            }
        }
        return null;
    }
    public static Goodstable getGoodsById(BigDecimal goodsId) {//葫芦娃
        for (int i = 0; i < Goodslist.length; i++) {
            if (Goodslist[i] != null && goodsId.compareTo(Goodslist[i].getGoodsid()) == 0&&Goodslist[i].getUsetime() > 0) {
                return Goodslist[i];
            }
        }
        return null;
    }

    public static Integer getGoodsIndexById(BigDecimal rgid) {
        for (int i = 0; i < Goodslist.length; i++) {
            if (Goodslist[i] != null && rgid.compareTo(Goodslist[i].getRgid()) == 0) {
                return i;
            }
        }
        return null;
    }
    /**
     * 符石卸下 格子不够返回false
     */
    public static boolean Unloadfushi(BigDecimal id) {
        for (int i = 0; i < Goodslist.length; i++) {
            if (Goodslist[i] == null) {
                Goodslist[i] = fushis.get(id);
                fushis.remove(id);
                PageNumberChange(Pagenumber);
                return true;
            }
        }
        return false;
    }

    /**通过皮肤获取物品图片*/
    public static ImageIcon imgpath(String skin) {
        ImageIcon img = CutButtonImage.getImage("img/item/" + skin + ".png", -1, -1);
        return img;
    }
    public static ImageIcon imgpath2(String skin) {
        ImageIcon img = CutButtonImage.getImage("img/item/" + skin + ".png", 43, 43);
        return img;
    }
    public static ImageIcon imgpathAdaptive(String skin, int width, int height) {
        ImageIcon img = CutButtonImage.getImage("img/item/" + skin + ".png", width, height);
        return img;
    }

    /**
     * 切换页数 传入切换到的页数 0为第一页
     */
    public static void PageNumberChange(int number) {
        Pagenumber = number;
        for (int i = Pagenumber * 24; i < (Pagenumber + 1) * 24; i++) {
            if (Goodslist[i] != null) {
                goodimg[i - Pagenumber * 24] = imgpath(Goodslist[i].getSkin());
            } else {
                goodimg[i - Pagenumber * 24] = null;
            }
        }
    }

    /**
     * 穿戴装备与背包物品切换 传入 装备和传入物品的位置
     *
     * @return
     * @throws Exception
     */
    public static void MutualChange(int Equipmentid, int good) throws Exception {
    	if(RoleData.getRoleData().getLoginResult().getFly_id()!=0){
            ZhuFrame.getZhuJpanel().addPrompt("飞行当中无法更换装备！");
            return;
        }
        if (Equipmentid != -1 && good != -1) {
            Goodstable goodstable = null;
            if (choseGoodsList[Equipmentid] != null) {
                choseGoodsList[Equipmentid].setStatus(0);
                goodstable = choseGoodsList[Equipmentid];
            }
            Goodslist[good].setStatus(1);
            GoodsMouslisten.gooduse(goodstable, Goodslist[good], 0);
            choseGoodsList[Equipmentid] = Goodslist[good];
            Goodslist[good] = goodstable;
            // 图片显示切换
            if (Goodslist[good] != null) {
                goodimg[good - Pagenumber * 24] = imgpath(Goodslist[good].getSkin());
            } else {
                goodimg[good - Pagenumber * 24] = null;
            }
        } else if (good == -1) {// 脱装备
            // 判断是身上的装备脱下来
            boolean Full = true;
            for (int i = 0; i < Goodslist.length; i++) {
                if (Goodslist[i] == null) {
                    choseGoodsList[Equipmentid].setStatus(0);
                    GoodsMouslisten.gooduse(choseGoodsList[Equipmentid], 0);
                    Goodslist[i] = choseGoodsList[Equipmentid];
                    if (i >= Pagenumber * 24 && i < (Pagenumber + 1) * 24) {// 判断背包物品位置是否需要显示
                        goodimg[i - Pagenumber * 24] = imgpath(Goodslist[i].getSkin());
                    }
                    choseGoodsList[Equipmentid] = null;// 装备图片清空
                    Full = false;
                    break;
                }
            }
            if (Full) {// 判断背包是否满了
                ZhuFrame.getZhuJpanel().addPrompt2("背包已满");
                return;
            }
        }
        // 1|3|6|8|11
        RoleProperty.getRoleProperty().equipWearOff();
        Thread.sleep(5);
        TimeLimit.getLimits().changeSkin();
    }

    /** 获取指定背包物品 */
    public static Goodstable Getgood(int Position) {
        if(Goodslist.length > Pagenumber * 24 + Position){
            return Goodslist[Pagenumber * 24 + Position];
        }else{
            return null;
        }

    }

    /** 根据传入的物品集合分类物品信息 */
    public static void Classification(List<Goodstable> goodstables, String packrecord) {
        if (goodstables.size() != 0) {
            if (goodstables.get(0).getRole_id().longValue() != ImageMixDeal.userimg.getRoleShow().getRole_id()
                    .longValue()) {
                return;
            }
        }
        GoodExpansion(ImageMixDeal.userimg.getRoleShow().getTurnAround(),ImageMixDeal.userimg.getRoleShow().getAttachPack());
        DDGoodUntil.ddgood.clear();
        fushis.clear();
        wingGoodsList.clear();
        starCardList.clear();
        for (int i = 0; i < choseGoodsList.length; i++) {
            choseGoodsList[i] = null;
        }
        ShouhuPackJframe.getShouhuPackJframe().getShouhuPackJpanel();
        int s = 0;
        // 先归类
        for (int i = goodstables.size() - 1; i >= 0; i--) {
            Goodstable goodstable = goodstables.get(i);
            if (goodstable.getType()==2255){
                if (goodstable.getStatus()!=0){
                    goodstables.remove(i);
                    ShouhuPackJframe.getShouhuPackJframe().getShouhuPackJpanel().getGoodstableList().remove(goodstable);
                    ShouhuPackJframe.getShouhuPackJframe().getShouhuPackJpanel().Eqment.add(goodstable);
                }  else {
                    ShouhuPackJframe.getShouhuPackJframe().getShouhuPackJpanel().getGoodstableList().add(goodstable);
                }
            }else
            if (goodstable.getType() == 8888) {
                wingGoodsList.add(goodstable);
                if (goodstable.getStatus() == 1) {
                    choseGoodsList[12] = goodstable;
                }
                goodstables.remove(i);
                continue;
            } else if (goodstable.getType() == 520 && (goodstable.getStatus() == 4 || goodstable.getStatus() == 1)) {
                if (goodstable.getStatus() == 1) {
                    choseGoodsList[13] = goodstable;
                }
                starCardList.add(goodstable);
                goodstables.remove(i);
                continue;
            } else if (goodstable.getStatus() == 1) {
                if (goodstable.getType() == 188 || goodstable.getType() == 729 || goodstable.getType() == 750
                        || Goodtype.baoshi(goodstable.getType())
                        || (goodstable.getType() >= 54 && goodstable.getType() <= 61)
                        || Goodtype.isSummonEquip(goodstable.getType()) || Goodtype.isPalEquip(goodstable.getType())) {
                    // 属于符石的
                    fushis.put(goodstables.get(i).getRgid(), goodstables.get(i));
                } else {
                    // 属于装备的
                    int Equipment = Goodtype.EquipmentType(goodstables.get(i).getType());
                    if (Equipment != -1) {
                        if (Equipment != 10) {
                            choseGoodsList[Equipment] = goodstables.get(i);
                            
                         // 身上装备是神兵
                        	if (goodstables != null && Goodtype.GodEquipment_God(goodstables.get(i).getType())) {
                        		String value = goodstables.get(i).getValue();
                        		if (value != null && value != "") {
                        			String[] vs = value.split("\\|");
                        			for (String v : vs) {
                        				String[] kv = v.split("=");
                    					if (kv.length == 2 && "等级".equals(kv[0]) && "6".equals(kv[1])) {
                    						s++;
                    						break;
                    					}
                    				}
                        		}
                        	} else if (goodstables != null && Goodtype.GodEquipment_xian(goodstables.get(i).getType())||Goodtype.GodEquipment_Ding(goodstables.get(i).getType())) {
                        		String value = goodstables.get(i).getValue();
                        		if (value != null && value != "") {
                        			String[] vs = value.split("\\|");
                        			for (String v : vs) {
                        				String[] kv = v.split("=");
                    					if (kv.length == 2 && "阶数".equals(kv[0]) && "6".equals(kv[1])) {
                    						s++;
                    						break;
                    					}
                    				}
                        		}
                        	}
                            
                        } else if (Equipment == 10 && choseGoodsList[10] == null) {
                            choseGoodsList[Equipment] = goodstables.get(i);
                        } else if (Equipment == 10 && choseGoodsList[10] != null) {
                            choseGoodsList[11] = goodstables.get(i);
                        }
                    } else {
                        goodstable.setUsetime(0);
                        GoodsMouslisten.gooduse(goodstable, 1);
                    }
                }
                goodstables.remove(i);
                continue;
            } else if (goodstable.getStatus() == 2) {
                // 存放进典当的背包
                DDGoodUntil.addddgood(goodstables.get(i));
                goodstables.remove(i);
                continue;
            } else if (goodstable.getUsetime() <= 0) {
                goodstables.remove(i);
                continue;
            }
        }
        NB = s;
        tiankeng(goodstables);
        if (packrecord != null && !"".equals(packrecord)) {
            try {
                String[] vs = packrecord.split("\\|");
                for (int i = 0; i < vs.length; i++) {
                    String[] vvs = vs[i].split("-");
                    if(vvs[0].contains("null")){
                        continue;
                    }
                    int p = Integer.parseInt(vvs[0]);
                    if (p >= Goodslist.length) {
                        continue;
                    }
                    BigDecimal rgid = new BigDecimal(vvs[1]);
                    for (int j = 0; j < goodstables.size(); j++) {
                        Goodstable good = goodstables.get(j);
                        if (good.getRgid().compareTo(rgid) == 0) {
                            if (Goodslist[p] == null) {
                                if (good.getType()==2255) {
                                    if (good.getStatus()!=0){
                                        goodstables.remove(good);
                                    }else{
                                        Goodslist[p] = good;
                                    }
                                }else{
                                    Goodslist[p] = good;
                                }

                            }
                            break;
                        }
                    }
                }
            } catch (Exception e) {
                // TODO: handle exception
                e.printStackTrace();
            }
        }
        weidaima(goodstables);
        // 显示背包和装备图片
        PageNumberChange(Pagenumber);
        //初始化快捷键的图片
        ZhuFrame.getZhuJpanel().hotKeyImg();
    }

    /** 填交易摆摊炼妖面板的坑 */
    public static boolean tiankeng(Goodstable good) {
        InternalForm form = FormsManagement.getInternalForm2(16);
        if (form != null) {
            Stall stall = ((BoothBoxJframe) form.getFrame()).getBoothboxjpanel().getStall2();
            ((BoothBoxJframe) form.getFrame()).getBoothboxjpanel().getStall();
            if (stall != null && (stall.getState() == StallBean.PREPARE || stall.getState() == StallBean.NO)) {
                Commodity[] commodities = stall.getGoodstables();
                for (int i = 0; i < commodities.length; i++) {
                    Goodstable goodstable = commodities[i] != null ? commodities[i].getGood() : null;
                    if (goodstable != null) {
                        if (good.getRgid().compareTo(goodstable.getRgid()) == 0) {
                            good.goodxh(goodstable.getUsetime());
                            if (good.getUsetime() <= 0) {
                                return true;
                            }
                            break;
                        }
                    }
                }
            }
        }
        form = FormsManagement.getInternalForm2(14);
        if (form != null) {
            GoodTrans goodTrans = ((TransJframe) form.getFrame()).getTransJpanel().getGoodTrans();
            if (goodTrans != null && goodTrans.getGoods() != null) {
                for (int i = 0; i < goodTrans.getGoods().size(); i++) {
                    Goodstable goodstable = goodTrans.getGoods().get(i);
                    if (good.getRgid().compareTo(goodstable.getRgid()) == 0) {
                        good.goodxh(goodstable.getUsetime());
                        if (good.getUsetime() <= 0) {
                            return true;
                        }
                        break;
                    }
                }
            }
        }
        return false;
    }

    public static void tiankeng(List<Goodstable> goods) {
        InternalForm form = FormsManagement.getInternalForm2(16);
        if (form != null) {
            Stall stall = ((BoothBoxJframe) form.getFrame()).getBoothboxjpanel().getStall2();
            if (stall != null && (stall.getState() == StallBean.PREPARE || stall.getState() == StallBean.NO)) {
                Commodity[] commodities = stall.getGoodstables();
                for (int i = 0; i < commodities.length; i++) {
                    Goodstable goodstable = commodities[i] != null ? commodities[i].getGood() : null;
                    if (goodstable != null) {
                        for (int j = goods.size() - 1; j >= 0; j--) {
                            Goodstable good = goods.get(j);
                            if (good.getRgid().compareTo(goodstable.getRgid()) == 0) {
                                good.goodxh(goodstable.getUsetime());
                                if (good.getUsetime() <= 0) {
                                    goods.remove(j);
                                }
                                break;
                            }
                        }
                    }
                }
            }
        }
        form = FormsManagement.getInternalForm2(14);
        if (form != null) {
            TransJpanel transJpanel = ((TransJframe) form.getFrame()).getTransJpanel();
            GoodTrans goodTrans = transJpanel.getGoodTrans();
            if (goodTrans != null && goodTrans.getGoods() != null) {
                for (int i = 0; i < goodTrans.getGoods().size(); i++) {
                    Goodstable goodstable = goodTrans.getGoods().get(i);
                    for (int j = goods.size() - 1; j >= 0; j--) {
                        Goodstable good = goods.get(j);
                        if (good.getRgid().compareTo(goodstable.getRgid()) == 0) {
                            good.goodxh(goodstable.getUsetime());
                            if (good.getUsetime() <= 0) {
                                goods.remove(j);
                            }
                            break;
                        }
                    }
                }
            }
        }
    }

    /** 伪代码 背包不自动整理 */
    public static void weidaima(List<Goodstable> goods) {
        List<Integer> you = new ArrayList<>();
        List<Integer> no = new ArrayList<>();
        for (int i = 0; i < Goodslist.length; i++) {
            if (Goodslist[i] == null) {
                no.add(i);
            } else {
                you.add(i);
            }
        }
        for (int i = goods.size() - 1; i >= 0; i--) {
            Goodstable good = goods.get(i);
            for (int j = you.size() - 1; j >= 0; j--) {
                Goodstable good2 = Goodslist[you.get(j)];
                if (good2.getRgid().longValue() == good.getRgid().longValue()) {
                    Goodslist[you.get(j)] = good;
                    goods.remove(i);
                    you.remove(j);
                    break;
                }
            }
        }
        for (int j = you.size() - 1; j >= 0; j--) {
            no.add(you.get(j));
            Goodslist[you.get(j)] = null;
        }
        int size1 = no.size();
        int size2 = goods.size();
        for (int i = 0; i < size1 && i < size2; i++) {
            Goodslist[no.get(i)] = goods.get(i);
        }
    }

    // 判断是否发送背包数据
    public static void isSendPackRecord() {
        String sendmes = getPackRecord();
        PackRecord packRecord = RoleData.getRoleData().getPackRecord();
        if (packRecord.getRecord() == null || !packRecord.getRecord().equals(sendmes)) {
            packRecord.setRecord(sendmes);
            sendPackRecord(0, sendmes);
        }
    }
    
    
    

    /** 发送背包记忆数据 0背包数据 1召唤兽支援数据 2灵宝支援数据3修改收录最大数量 6 召唤兽排序数据*/
    public static void sendPackRecord(int type, String msg) {
        String sendmes = Agreement.getAgreement().packRecordAgreement(type + msg);
        SendMessageUntil.toServer(sendmes);
    }

    
    
    
    /** 生成背包记忆格式 */
    public static String getPackRecord() {
        StringBuffer buffer = new StringBuffer();
        for (int i = 0; i < Goodslist.length; i++) {
            if (Goodslist[i] != null) {
                if (buffer.length() != 0) {
                    buffer.append("|");
                }
                buffer.append(i);
                buffer.append("-");
                buffer.append(Goodslist[i].getRgid());
            }
        }
        return buffer.toString();
    }
    /**
     * 当前页整理
     */
    public static void arrange(){
        Goodstable[] gs = new Goodstable[24];
        int i = 0;
        for (int j = Pagenumber * 24; j < (Pagenumber + 1) * 24; j++){
            Goodstable goodstable = Goodslist[j];
            if (goodstable != null) {
                gs[i++] = goodstable;
            }
        }
        sort(gs);
        i = 0;
        for (int j = Pagenumber * 24; j < (Pagenumber + 1) * 24; j++){
            Goodslist[j] = gs[i++];//....
        }
//        Goodslist = gs;
        PageNumberChange(Pagenumber);
    }
    /** 全局整理 */
    public static void allArrange() {
        Goodstable[] gs = new Goodstable[Goodslist.length];
        int i = 0;
        for (Goodstable goodstable : Goodslist) {
            if (goodstable != null) {
                gs[i++] = goodstable;
            }
        }
        sort(gs);
        Goodslist = gs;
        PageNumberChange(Pagenumber);
    }

    /**
     * 排序
     * @param objects
     */
    public static void sort(Goodstable[] objects){
        for(int i = 0; i < objects.length - 1; i++){
            for (int j = 0; j < objects.length - i - 1; j++){
            	if(objects[j+1] == null) {
                    break;
                }
                if (objects[j].getGoodsid().longValue() > objects[j+1].getGoodsid().longValue()){
                    Goodstable temp = objects[j];
                    objects[j] = objects[j + 1];
                    objects[j + 1] = temp;
                }
            }
        }
    }
    /** 转生背包扩充      扩展背包 */
    public static void GoodExpansion(int TurnAround, int attachPack) {
        ConfigureBean allConfigure = UserMessUntil.getConfigureBean();
        Map<BigDecimal, Configure> item = allConfigure.getAllConfigure();
        Configure configure = item.get(new BigDecimal(1));
        if (TurnAround >= 4) {
            TurnAround = 3;
        }
        int Total = (1+ TurnAround + attachPack) * 24;
        if (Goodslist != null) {
            if (Total != Goodslist.length) {
                Goodstable[] Goodslists = new Goodstable[Total];
                for (int i = 0; i < Goodslist.length; i++) {
                    Goodslists[i] = Goodslist[i];
                }
                Goodslist = Goodslists;
            }
        } else {
            Goodslist = new Goodstable[Total];
        }
        int keyong = Total / 24;
        // 按钮设置
        //25-Oct-2821 12∶44:14.284严重[ajp-nio-8B11-exec-4] org.apache.coyote.ajp.9.jpMessage.processHeader Invalid message received with signature [5635]
        //25-10月-2821 12：44：14.284严重[ajp-nio-8B11-exec-4]收到的带有签名的org.apache.coyote.ajp.9.jpMessage.processHeader无效消息[5635]
        goodbtn[] ds = TestpackJframe.getTestpackJframe().getJpac().getBtnrights();
        btntype(ds, keyong);
        btntype(ForgeJframe.getForgejframe().getJpanel().getBtnrights(), keyong);
        btntype(GiveJframe.getGivejframe().getGivejpanel().getBtnrights(), keyong);
        btntype(TradeJframe.getTradejframe().getTradejpanel().getBtnrights(), keyong);
        if(!"3".equals(configure.getLzjskg())) {
            btntype(WorkshopRefiningJframe.getWorkshopRefiningJframe().getWorkshopRefiningJpanel().getCardJpanel()
                    .getRefinersJpanel().getBtnrights(), keyong);
        }
        btntype(WorkshopRefiningJframe.getWorkshopRefiningJframe().getWorkshopRefiningJpanel().getCardJpanel()
                .getEquiJpanel().getBtnrights(), keyong);
        btntype(WorkshopRefiningJframe.getWorkshopRefiningJframe().getWorkshopRefiningJpanel().getCardJpanel()
                .getEquiJpanel2().getBtnrights(), keyong);
        btntype(ExchangeValueJframe.getExchangeValueJframe().getValueJpanel().getBtnrights(), keyong);
        btntype(CollectionJadeJframe.getCollectionJadeJframe().getJadeJpanel().getBtnrights(), keyong);
        btntype(PetEquipmentJframe.getPetEquipmentJframe().getEquipmentJpanel().getBtnrights(), keyong);
        btntype(TransJframe.getTransJframe().getTransJpanel().getBtnrights(), keyong);
        btntype(AlchemyJframe.getAlchemyjframe().getalchemyJpanel().getBtnrights(), keyong);
        btntype(RuneOperateJframe.getRuneOperateJframe().getOperateJpanel().getBtnrights(), keyong);
        //典当面板包裹切换按钮显示
        btntype( PawnJfram.getPawnJfram().getPawnjpanel().getBtnrights(), keyong);
        btntype(BaiTanJframe.getBaiTanJframe().getBaiTanJpanel().getPack(),keyong);
        if(!"3".equals(configure.getLzjskg())) {
            TestpackJframe.getTestpackJframe().getJpac().getBtnrights()[Pagenumber].dianji();
        }

    }

    // /**重置可用按钮类型*/
    public static void btntype(goodbtn[] btnrights, int path) {
        for (int i = 0; i < btnrights.length && i < path; i++) {
            btnrights[i].btntypechange(2);
        }
    }

    /** 新添加的物品 */
    public static void newgood(List<Goodstable> goodstables) {
        for (int i = 0; i < goodstables.size(); i++) {
            for (int j = 0; j < Goodslist.length; j++) {
                if (Goodslist[j] == null) {
                    Goodslist[j] = goodstables.get(i);
                    break;
                }
            }
        }
        PageNumberChange(Pagenumber);
    }

    /** 判断角色是否拥有这个物品 且可以重叠 */
    public static int chongfu(Goodstable goodstable) {
        int goodid = goodstable.getGoodsid().intValue();
        if (!EquipTool.isEquip(goodstable.getType())) {
            for (int i = 0; i < Goodslist.length; i++) {
                if (Goodslist[i].getGoodsid().intValue() == goodid) {
                    return i;
                }
            }
        }
        return -1;
    }

    /** 新添加的物品 */
    public static boolean newgood(Goodstable goodstables) {
        for (int j = 0; j < Goodslist.length; j++) {
            if (Goodslist[j] == null) {
                goodstables.setStatus(0);
                Goodslist[j] = goodstables;
                PageNumberChange(Pagenumber);
                return true;
            }
        }
        return false;
    }

    /** 批量查找满足条件的物品 放回lsit */
    public static List<Integer> chaxuns(int[] goodids) {
        List<Integer> weizhi = new ArrayList<>();
        ss: for (int i = 0; i < goodids.length; i++) {
            int id = goodids[i];
            int sum = 0;
            for (int j = 0; j < goodids.length; j++) {
                if (id == goodids[j]) {
                    sum++;
                }
            }
            for (int j = 0; j < Goodslist.length; j++) {
                if (Goodslist[j] != null) {
                    if (Goodslist[j].getGoodsid().intValue() == id) {
                        if (Goodslist[j].getUsetime() >= sum) {
                            weizhi.add(j);
                            continue ss;
                        }
                    }
                }
            }
        }
        // 判断是否所有物品都查询到 没查询到返回null
        return weizhi.size() == goodids.length ? weizhi : null;
    }

    public static int chaxuns(int goodid) {
        for (int j = 0; j < Goodslist.length; j++) {
            if (Goodslist[j] != null) {
                if (Goodslist[j].getGoodsid().intValue() == goodid) {
                    return j;
                }
            }
        }
        return -1;
    }

    /** 查找满足类型的全部物品返回物品 */
    public static List<Goodstable> chaxunss(long type) {
        List<Goodstable> weizhi = new ArrayList<>();
        for (int i = 0; i < Goodslist.length; i++) {
            if (Goodslist[i] != null && Goodslist[i].getType() == type) {
                weizhi.add(Goodslist[i]);
            }
        }
        return weizhi;
    }
    /** 删除指定位置的物品 放回表id集合 */
    public static void Deleted(int goodid) {
        Goodslist[goodid] = null;
        PageNumberChange(Pagenumber);
    }

    /** 批量道具使用一次 放回表id集合 */
    public static void Delete(List<Integer> goodids) {
        GoodsMouslisten.goodarr.setI(1);
        List<Goodstable> list = GoodsMouslisten.goodarr.getList();
        list.clear();
        for (int i = 0; i < goodids.size(); i++) {
            Goodslist[goodids.get(i)].goodxh(1);
            if (!list.contains(Goodslist[goodids.get(i)])) {
                list.add(Goodslist[goodids.get(i)]);
            }
        }
        String sendmes = Agreement.getAgreement().packchangeAgreement(
                GsonUtil.getGsonUtil().getgson().toJson(GoodsMouslisten.goodarr));
        // 将装备物品返还给客户端// 向服务器发送信息
        SendMessageUntil.toServer(sendmes);
        for (int i = 0; i < goodids.size(); i++) {
            if (Goodslist[goodids.get(i)] != null) {
                if (Goodslist[goodids.get(i)].getUsetime() <= 0) {
                    Goodslist[goodids.get(i)] = null;
                }
            }
        }
        PageNumberChange(Pagenumber);
    }

    /** 批量道具使用一次 放回表id集合 */
    public static List<BigDecimal> Delete2(List<Integer> goodids) {
        List<BigDecimal> list = new ArrayList<>();
        for (int i = 0; i < goodids.size(); i++) {
            Goodstable good = Goodslist[goodids.get(i)];
            if (good != null) {
                good.goodxh(1);
                list.add(good.getRgid());
                if (good.getUsetime() <= 0) {
                    Goodslist[goodids.get(i)] = null;
                }
            }

        }
        PageNumberChange(Pagenumber);
        return list;
    }

    public static List<BigDecimal> Delete(int goodids) {
        List<BigDecimal> biaoids = new ArrayList<>();
        if (Goodslist[goodids] == null) {
            return null;
        }
        biaoids.add(Goodslist[goodids].getRgid());
        Goodslist[goodids] = null;
        PageNumberChange(Pagenumber);
        return biaoids;
    }

    /** 根据表id来删除物品 */
    public static void Deletebiaoid(BigDecimal biaoid) {
        for (int i = 0; i < Goodslist.length; i++) {
            if (Goodslist[i] != null) {
                if (Goodslist[i].getRgid().intValue() == biaoid.intValue()) {
                    if (Goodslist[i].getUsetime() <= 0 || Goodslist[i].getStatus() != 0) {
                        Goodslist[i] = null;
                        PageNumberChange(Pagenumber);
                        return;
                    }
                }
            }
        }
    }

    /** 表id使用一次 */
    public static Goodstable Uerbiaoid(BigDecimal biaoid) {

        for (int i = 0; i < Goodslist.length; i++) {
            if (Goodslist[i] != null) {
                Goodstable goodstable = Goodslist[i];
                if (goodstable.getRgid().intValue() == biaoid.intValue()) {
                    goodstable.goodxh(1);
                    if (goodstable.getUsetime() <= 0) {
                        Goodslist[i] = null;
                        PageNumberChange(Pagenumber);
                    }
                    return goodstable;
                }
            }
        }
        return null;
    }
    public static List<Goodstable> getGoodsListByGoodsId(BigDecimal goodsId) {
        List<Goodstable> goodsList = new ArrayList<>();
        for (int i = 0; i < Goodslist.length; i++) {
            if (Goodslist[i] != null) {
                if (Goodslist[i].getGoodsid().compareTo(goodsId) == 0) {
                    goodsList.add(Goodslist[i]);
                }
            }
        }
        return goodsList;
    }
    // 获取表id
    public static Goodstable getRgid(BigDecimal rgid) {
        Goodstable good = fushis.get(rgid);
        if (good != null) {
            return good;
        }
        for (int i = 0; i < Goodslist.length; i++) {
            if (Goodslist[i] != null) {
                if (Goodslist[i].getRgid().compareTo(rgid) == 0) {
                    return Goodslist[i];
                }
            }
        }
        for (int i = 0; i < choseGoodsList.length; i++) {
            if (choseGoodsList[i] != null) {
                if (choseGoodsList[i].getRgid().compareTo(rgid) == 0) {
                    return choseGoodsList[i];
                }
            }
        }
        for (int i = wingGoodsList.size() - 1; i >= 0; i--) {
            good = wingGoodsList.get(i);
            if (good.getRgid().compareTo(rgid) == 0) {
                return good;
            }
        }
        for (int i = starCardList.size() - 1; i >= 0; i--) {
            good = starCardList.get(i);
            if (good.getRgid().compareTo(rgid) == 0) {
                return good;
            }
        }
        return null;
    }

    /** 查询id 和数量判断是否足够 */
    public static boolean isgood(int goodid, int sum) {
        int sysum = 0;
        for (int i = 0; i < Goodslist.length; i++) {
            if (Goodslist[i] == null) {
                continue;
            }
            if (Goodslist[i].getGoodsid().intValue() != goodid) {
                continue;
            }
            sysum += Goodslist[i].getUsetime();
            if (sysum >= sum) {
                return true;
            }
        }
        return false;
    }

    /** 使用id 和数量 */
    public static boolean consume(int goodid, int sum) {
        int sysum = sum;
        for (int i = 0; i < Goodslist.length; i++) {
            if (sum <= 0) {
                break;
            }
            if (Goodslist[i] == null) {
                continue;
            }
            if (Goodslist[i].getGoodsid().intValue() != goodid) {
                continue;
            }
            Goodstable goodstable = Goodslist[i];
            if (goodstable.getUsetime() >= sysum) {
                sum = 0;
                goodstable.setUsetime(goodstable.getUsetime() - sysum);
            } else {
                sum -= goodstable.getUsetime();
                goodstable.setUsetime(0);
            }
            if (goodstable.getUsetime() <= 0) {
                Goodslist[i] = null;
                GoodsMouslisten.gooduse(goodstable, 1);
            }
            if (sum <= 0) {
                break;
            }
        }
        PageNumberChange(Pagenumber);
        return false;
    }

    /** 2个物品格子的替换 */
    public static void tihuan(int one, int two) {
        Goodstable goodstable = Goodslist[one];
        Goodslist[one] = Goodslist[two];
        Goodslist[two] = goodstable;
        PageNumberChange(Pagenumber);
        //背包实时更新物位置，可能导致服务器卡，人多的时候
        GoodsListFromServerUntil.isSendPackRecord();
    }

    /** 根据类型和 数量判断格子是否足够 */
    public static int Surplussum(String type, String id, int sum) {
        int size = 0;
        // 先判断物品是否可以重叠
        if (!EquipTool.isEquip(Long.parseLong(type))) {
            // 可重叠
            for (int i = 0; i < Goodslist.length; i++) {
                if (Goodslist[i] == null) {
                    return sum;
                } else if (id.equals(Goodslist[i].getGoodsid() + "")) {
                    return sum;
                }
            }
        } else {
            // 不可重叠
            for (int i = 0; i < Goodslist.length; i++) {
                if (Goodslist[i] == null) {
                    size++;
                    if (size >= sum) {
                        return sum;
                    }
                }
            }
        }
        return size;
    }

    /** 判断格子数是否够（在购买物品的时候使用） */
    public static boolean sureCanBuyOrNo(String id) {
        boolean sureCanbuOrNo = false;
        // 判断背包里面有没有这个物品或者是否有多余的空格来装东西
        for (int i = 0; i < Goodslist.length; i++) {
            if (Goodslist[i] == null) {
                sureCanbuOrNo = true;
            } else if (id.equals(Goodslist[i].getGoodsid() + "")) {
                if (Surplussum(Goodslist[i].getType() + "", id, 1) > 0) {
                    sureCanbuOrNo = true;
                }
            }
        }
        // 如果没有，判断格子数目是否为空
        return sureCanbuOrNo;
    }

    /** 修改物品数量 */
    public static void addGood(BigDecimal id, int sum) {
        Goodstable good = fushis.get(id);
        if (good != null) {
            good.setUsetime(sum);
            if (sum == 0) {
                fushis.remove(good);
            }
        }
        for (int i = Goodslist.length - 1; i >= 0; i--) {
            if (Goodslist[i] == null) {
                continue;
            }
            good = Goodslist[i];
            if (good.getRgid().compareTo(id) == 0) {
                good.setUsetime(sum);
                if (tiankeng(good)) {
                    Goodslist[i] = null;
                    PageNumberChange(Pagenumber);
                } else if (good.getUsetime() <= 0) {
                    Goodslist[i] = null;
                    PageNumberChange(Pagenumber);
                }
                ZFShow(good);
                return;
            }
        }
        for (int i = choseGoodsList.length - 1; i >= 0; i--) {
            if (choseGoodsList[i] == null) {
                continue;
            }
            good = choseGoodsList[i];
            if (good.getRgid().compareTo(id) == 0) {
                good.setStatus(0);
                good.setUsetime(sum);
                choseGoodsList[i] = null;
                ZFShow(good);
                return;
            }
        }
        for (int i = wingGoodsList.size() - 1; i >= 0; i--) {
            good = wingGoodsList.get(i);
            if (good.getRgid().compareTo(id) == 0) {
                good.setUsetime(sum);
                if (good.getUsetime() <= 0) {
                    wingGoodsList.remove(i);
                }
                return;
            }
        }
        for (int i = starCardList.size() - 1; i >= 0; i--) {
            good = starCardList.get(i);
            if (good.getRgid().compareTo(id) == 0) {
                good.setUsetime(sum);
                if (good.getUsetime() <= 0) {
                    starCardList.remove(i);
                }
                return;
            }
        }
        Goodstable goodstable1=UserMessUntil.getgoodstable(id);
        if (goodstable1!=null&&goodstable1.getGoodsname().equals("还我漂漂丹")){
         TimeLimit.good();
        }
       ;
    }

    /** 新添加的物品 不为空添加成功 空添加失败 */
    public static void addGood(Goodstable goodstable) {
        if (goodstable.getType() == -1) {
            RoleData.getRoleData().addTx(-goodstable.getGoodsid().longValue() + "");
            return;
        }
        if (goodstable.getType() == 8888) {
            addWingGood(goodstable);
            return;
        }
        if (goodstable.getType() == 520 && (goodstable.getStatus() == 4 || goodstable.getStatus() == 1)) {
            addStarCard(goodstable);
            return;
        }
        if (tiankeng(goodstable)) {
            return;
        }

        if (Goodtype.isSummonEquip(goodstable.getType())) {
            JframeSummonEquipMain equipMain = JframeSummonEquipMain.getShowJframeSummonEquipMain();
            if (equipMain != null) {
                /** 召唤兽装备面板刷新 */
                JpanelSummonEquipMain jpanelSummonEquipMain = equipMain.getJpanelSummonEquipMain();
                if (jpanelSummonEquipMain.getChooseEquip() != null
                        && jpanelSummonEquipMain.getChooseEquip().compareTo(goodstable.getRgid()) == 0) {
                    jpanelSummonEquipMain.refreshEquipOneImg(goodstable);
                }
            }
        }

        fushis.remove(goodstable.getRgid());
        if (goodstable.getStatus() == 1) {
            if (goodstable.getUsetime() > 0) {
                if (goodstable.getType() == 188 || goodstable.getType() == 729 || goodstable.getType() == 750
                        || Goodtype.baoshi(goodstable.getType())
                        || (goodstable.getType() >= 54 && goodstable.getType() <= 61)
                        || Goodtype.isSummonEquip(goodstable.getType()) || Goodtype.isPalEquip(goodstable.getType())) {
                    fushis.put(goodstable.getRgid(), goodstable);
                }
            }
            for (int i = Goodslist.length - 1; i >= 0; i--) {
                if (Goodslist[i] != null && Goodslist[i].getRgid().compareTo(goodstable.getRgid()) == 0) {
                    Goodslist[i] = null;
                    PageNumberChange(Pagenumber);
                    break;
                }
            }
            for (int i = choseGoodsList.length - 1; i >= 0; i--) {
            	if (choseGoodsList[i] != null && choseGoodsList[i].getRgid().compareTo(goodstable.getRgid()) == 0) {
            		choseGoodsList[i] = goodstable;
                    break;
                }
            }
            return;
        }
        int ky = -1;
        for (int i = Goodslist.length - 1; i >= 0; i--) {
            if (Goodslist[i] == null) {
                ky = i;
                continue;
            }
            Goodstable good = Goodslist[i];
            if (good.getRgid().compareTo(goodstable.getRgid()) == 0) {
                ky = i;
                break;
            }
        }
        if (ky != -1) {
            String skin = Goodslist[ky] != null ? Goodslist[ky].getSkin() : null;
            if (goodstable.getUsetime() > 0) {
                Goodslist[ky] = goodstable;
            } else {
                Goodslist[ky] = null;
            }
            if (Goodslist[ky] == null || skin == null || !skin.equals(goodstable.getSkin())) {
                PageNumberChange(Pagenumber);
            }
            ZFShow(goodstable);
        }
    }

    /** 判断是否刷新作坊界面 */
    public static void ZFShow(Goodstable good) {
        InternalForm form = FormsManagement.getInternalForm2(61);
        if (form == null || !form.getFrame().isVisible()) {
            return;
        }
        WorkshopRefiningCardJpanel cardJpanel = ((WorkshopRefiningJframe) form.getFrame()).getWorkshopRefiningJpanel()
                .getCardJpanel();
        GemRefineryMainJpanel gemRefineryMainJpanel = cardJpanel.getGemRefineryMainJpanel();
        
        if(gemRefineryMainJpanel!=null && gemRefineryMainJpanel.isVisible()){
            if(gemRefineryMainJpanel.getChooseGoodstable() != null &&gemRefineryMainJpanel.getChooseGoodstable().getRgid().compareTo(good.getRgid()) == 0){
                gemRefineryMainJpanel.refreshChooseGoodstable(good,1);
            }else {
                gemRefineryMainJpanel.refreshChooseGoodstable(good,2);
            }
        }else{
            cardJpanel.getEquiJpanel().ResetGood(good);
            if(cardJpanel.getRefinersJpanel()!=null) {
            	cardJpanel.getRefinersJpanel().ResetGood(good);
            }
        }
    }

    /** 翅膀装备修改 */
    public static void addWingGood(Goodstable goodstable) {
        for (int i = wingGoodsList.size() - 1; i >= 0; i--) {
            Goodstable good = wingGoodsList.get(i);
            if (good.getRgid().compareTo(goodstable.getRgid()) == 0) {
                if (goodstable.getUsetime() <= 0) {
                    wingGoodsList.remove(i);
                } else {
                    wingGoodsList.set(i, goodstable);
                    if (goodstable.getStatus() == 1) {
                        choseGoodsList[12] = goodstable;
                        RoleProperty.getRoleProperty().equipWearOff();
                    }
                    if (FormsManagement.getframe(86).isVisible()) {
                        // 刷新翅膀界面
                        WingMainPanel wingMainPanel = WingMainFrame.getWingMainFrame().getWingMainPanel();
                        if (wingMainPanel.getWingGoods() != null
                                && wingMainPanel.getWingGoods().compareTo(goodstable.getRgid()) == 0) {
                            wingMainPanel.changeChooseWingGoods(goodstable, wingMainPanel.getWingGoodsType());
                        }
                    }
                }
                return;
            }
        }
        wingGoodsList.add(goodstable);
    }

    /** 星卡修改 */
    public static void addStarCard(Goodstable goodstable) {
        if (goodstable.getStatus() == 1) {
            choseGoodsList[13] = goodstable;
        }
        for (int i = starCardList.size() - 1; i >= 0; i--) {
            Goodstable good = starCardList.get(i);
            if (good.getRgid().compareTo(goodstable.getRgid()) == 0) {
                if (goodstable.getUsetime() <= 0) {
                    starCardList.remove(i);
                } else {
                    starCardList.set(i, goodstable);
                }
                if (good.getStatus() == 1 && goodstable.getStatus() == 4) {
                    choseGoodsList[13] = null;
                    RoleProperty.getRoleProperty().equipWearOff();
                }
                JframeStarCardMain jframeStarCardMain = JframeStarCardMain.getJframeSummonEquipMain();
                if (jframeStarCardMain != null) {
                    JpanelStarCardMain jpanelStarCardMain = jframeStarCardMain.getJpanelStarCardMain();
                    if (jpanelStarCardMain.getChooseStarCardId() != null
                            && goodstable.getRgid().compareTo(jpanelStarCardMain.getChooseStarCardId()) == 0) {
                        if (jpanelStarCardMain.getBigType() == 2) {
                            if (jpanelStarCardMain.getSmallType() == 1 || jpanelStarCardMain.getSmallType() == 4
                                    || jpanelStarCardMain.getSmallType() == 2) {
                                jpanelStarCardMain.viewChange(goodstable.getUsetime() <= 0 ? null : goodstable);
                            }
                        } else if (jpanelStarCardMain.getBigType() == 1) {
                            jpanelStarCardMain.attributeImgShow(goodstable.getUsetime() <= 0 ? null : goodstable);
                        }
                    }
                }
                JframeStarTransferMain jframeStarTransferMain = JframeStarTransferMain.getShowJframeStarTransferMain();
                if (jframeStarTransferMain != null) {
                    JpanelStarTransferMain jpanelStarTransferMain = jframeStarTransferMain.getJpanelStarTransferMain();
                    if (jpanelStarTransferMain.getChooseOneId() != null
                            && jpanelStarTransferMain.getChooseOneId().compareTo(goodstable.getRgid()) == 0) {
                        String[] values = goodstable.getValue().split("\\|");
                        String[] split2 = values[3].split("&");
                        for (int j = 0; j < split2.length; j++) {
                            if (split2[j].startsWith("星阵属性")) {
                                String[] split = split2[j].split("=");
                                if (BtnStarCard.isfiveElements(split[1])) {
                                    jpanelStarTransferMain.showStarCardAttribute(0, split,
                                            goodstable.getUsetime() <= 0 ? null : goodstable);
                                    jpanelStarTransferMain.showStarCardAttribute(1, null, null);
                                }
                            }
                        }
                    }
                }
                return;
            }
        }
        starCardList.add(goodstable);
    }

    /**
     * 装备替换 1表示在装备 2表示预装备
     *
     * @return
     */
    public static boolean ChangeParts(Goodstable good1, Goodstable good2) {
        // 获取good2的位置
        int p = -1;
        if (good2 != null) {
            for (int i = 0; i < Goodslist.length; i++) {
                if (Goodslist[i] == null) {
                    continue;
                }
                if (Goodslist[i].getRgid().compareTo(good2.getRgid()) != 0) {
                    continue;
                }
                Goodslist[i] = null;
                p = i;
                break;
            }
            good2.setStatus(1);
            GoodsMouslisten.gooduse(good2, 0);
        } else {
            for (int i = 0; i < Goodslist.length; i++) {
                if (Goodslist[i] != null) {
                    continue;
                }
                p = i;
                break;
            }
        }
        if (good1 != null) {
            if (p != -1) {
                Goodslist[p] = good1;
                good1.setStatus(0);
                GoodsMouslisten.gooduse(good1, 0);
            } else {
                return false;
            }
        }
        p -= Pagenumber * 24;
        if (p >= 0 && p < 24) {
            PageNumberChange(Pagenumber);
        }
        return true;

    }

    /** 封装的物品检测 true表示不在背包 */
    public static boolean isExist(Goodstable good) {
        for (int i = 0; i < Goodslist.length; i++) {
            if (Goodslist[i] == null) {
                continue;
            }
            if (good == Goodslist[i]) {
                if (Goodslist[i].getUsetime() <= 0) {
                    Goodslist[i] = null;
                    PageNumberChange(Pagenumber);
                    return true;
                }
                return false;
            }
        }
        ZhuFrame.getZhuJpanel().addPrompt2("物品已经不在背包了");
        return true;
    }

    /** 封装的物品检测 true表示不在装备栏 */
    public static boolean ischoseExist(Goodstable good) {
        for (int i = 0; i < choseGoodsList.length; i++) {
            if (choseGoodsList[i] == null) {
                continue;
            }
            if (good == choseGoodsList[i]) {
                return false;
            }
        }
        Goodstable goodstable = fushis.get(good.getRgid());
        if (goodstable != null && goodstable == good) {
            return false;
        }
        ZhuFrame.getZhuJpanel().addPrompt2("物品已经不在背包了");
        return true;
    }

    // 将摆摊的物品扣除
    public static void stall1(Goodstable goodstable) {
        for (int i = Goodslist.length - 1; i >= 0; i--) {
            if (Goodslist[i] == null) {
                continue;
            }
            Goodstable good = Goodslist[i];
            if (good.getRgid().compareTo(goodstable.getRgid()) == 0) {
                Goodslist[i].setUsetime(Goodslist[i].getUsetime() - goodstable.getUsetime());
                if (Goodslist[i].getUsetime() <= 0) {
                    Goodslist[i] = null;
                    PageNumberChange(Pagenumber);
                }
                return;
            }
        }
    }

    // 将摆摊的物品还回去
    public static void stall2(Goodstable goodstable) {
        int ky = -1;
        for (int i = Goodslist.length - 1; i >= 0; i--) {
            if (Goodslist[i] == null) {
                ky = i;
                continue;
            }
            Goodstable good = Goodslist[i];
            if (good.getRgid().compareTo(goodstable.getRgid()) == 0) {
                Goodslist[i].setUsetime(Goodslist[i].getUsetime() + goodstable.getUsetime());
                return;
            }
        }
        if (ky != -1) {
            Goodslist[ky] = goodstable;
            PageNumberChange(Pagenumber);
        }
    }

    /** 禁止交易的初步筛选 true禁交易 */
    public static boolean isJY(Goodstable good) {
        if (good.getGoodlock() == 1 || AnalysisString.jiaoyi(good.getQuality())) {return true;}
        if (Goodtype.EquipmentType(good.getType()) != -1) {
            if (AccessSuitMsgUntil.getExtra(good.getValue(), BaptizeBtn.Extras[3]) != null) {return true;}
            if (AccessSuitMsgUntil.getExtra(good.getValue(), BaptizeBtn.Extras[4]) != null) {return true;}
        }
        return false;
    }

    /** 获取背包物品id数量 */
    public static int getGoodNum(BigDecimal sid) {
        int size = 0;
        for (int i = 0; i < Goodslist.length; i++) {
            if (Goodslist[i] != null && Goodslist[i].getGoodsid().compareTo(sid) == 0) {
                size += Goodslist[i].getUsetime();
            }
        }
        return size;
    }



    // 升级界面物品获取
    public static Goodstable getUpgradeGoods(int type, WingMainPanel wingMainPanel) {
        int j = -(wingMainPanel.getPageNumber() - 1) * 15 - 1;
        for (int i = 0; i < Goodslist.length; i++) {
            if (Goodslist[i] == null) {
                continue;
            }
            if (++j < 0) {
                continue;
            }
            if (type == j) {
                return Goodslist[i];
            }
        }
        return null;
    }


    // 升级界面物品获取
    public static Goodstable getUpgradeGoods(int type, LHMainPanel wingMainPanel) {
        int j = -(wingMainPanel.getPageNumber() - 1) * 15 - 1;
        for (int i = 0; i < Goodslist.length; i++) {
            if (Goodslist[i] == null) {
                continue;
            }
            if (++j < 0) {
                continue;
            }
            if (type == j) {
                return Goodslist[i];
            }
        }
        return null;
    }

    /** 获取翅膀升星材料 */
    public static Goodstable getWingUpStarGoods(int type) {
        int number = 0;
        for (int i = 0; i < Goodslist.length; i++) {
            if (Goodslist[i] == null) {
                continue;
            }
            if (!Goodtype.upStarWing(Goodslist[i].getType())) {
                continue;
            }
            if (number == type) {
                return Goodslist[i];
            }
            number++;
        }
        return null;
    }

    // 翅膀升级物品图片展示
    public static void getUpgrade(Graphics g, WingMainPanel wingMainPanel, int x, int y) {
        int j = -(wingMainPanel.getPageNumber() - 1) * 15 - 1;
        for (int i = 0; i < Goodslist.length; i++) {
            if (Goodslist[i] == null) {
                continue;
            }
            if (++j < 0) {
                continue;
            }
            ImageIcon imgpathAdaptive = imgpathAdaptive(Goodslist[i].getSkin(), 49, 49);
            g.drawImage(imgpathAdaptive.getImage(), x + j % 5 * 51, y + j / 5 * 54, 49, 49, null);
            g.setColor(Color.red);
            g.drawString(Goodslist[i].getUsetime().toString(), x + j % 5 * 51 + 4, y + j / 5 * 54 + 10);
            if (j >= 14) {
                return;
            }
        }
    }

    // 获取升星材料
    public static void getGoodsUpStar(Graphics g, WingMainPanel wingMainPanel, int x, int y) {
        int j = 0;
        for (int i = 0; i < Goodslist.length; i++) {
            if (Goodslist[i] == null) {
                continue;
            }
            if (Goodtype.upStarWing(Goodslist[i].getType())) {
                g.drawImage(imgpathAdaptive(Goodslist[i].getSkin(), 49, 49).getImage(), x + j * 51, y, 49, 49, null);
                g.setColor(Color.red);
                g.drawString(Goodslist[i].getUsetime().toString(), x + j * 51 + 4, y + 10);
                j++;
                if (j > 4) {
                    return;
                }
            }
        }
    }

    // 翅膀品质面板的培养物品获取
    public static void getQualityGoods(Graphics g, WingMainPanel wingMainPanel, int x, int y) {
        Goodstable goodstable = UserMessUntil.getgoodstable(new BigDecimal(8890));
        if (goodstable == null) {
            // return;
        } else {
            g.drawImage(imgpathAdaptive(goodstable.getSkin(), 58, 56).getImage(), x, y, 58, 56, null);
        }
        for (int i = 0; i < Goodslist.length; i++) {
            if (Goodslist[i] == null) {
                continue;
            }
            if (Goodslist[i].getType() == 8890) {
                wingMainPanel.setChosegoods(Goodslist[i]);
                // g.drawImage(imgpathAdaptive(wingMainPanel.getChosegoods().getSkin(),
                // 58, 56).getImage(), x, y, 58, 56, null);
                g.setColor(Color.red);
                g.drawString(Goodslist[i].getUsetime().toString(), x + 2, y + 12);
                return;
            }
        }
        g.setColor(Color.red);
        g.drawString("0", x + 2, y + 12);
    }

    // 获取翅膀重铸界面的重铸物品
    public static void getRecastGoods(Graphics g, WingMainPanel wingMainPanel, int x, int y) {
        Goodstable goodstable = UserMessUntil.getgoodstable(new BigDecimal(8892));
        if (goodstable == null) {
            // return;
        } else {
            g.drawImage(imgpathAdaptive(goodstable.getSkin(), 49, 49).getImage(), x, y, 49, 49, null);
        }
        for (int i = 0; i < Goodslist.length; i++) {
            if (Goodslist[i] == null) {
                continue;
            }
            if (Goodslist[i].getType() == 8892) {
                wingMainPanel.setChosegoods(Goodslist[i]);
                // g.drawImage(imgpathAdaptive(wingMainPanel.getChosegoods().getSkin(),
                // 58, 56).getImage(), x, y, 58, 56, null);
                g.setColor(Color.red);
                g.drawString(Goodslist[i].getUsetime().toString(), x + 2, y + 12);
                return;
            }
        }
        g.setColor(Color.red);
        g.drawString("0", x + 2, y + 12);
    }

    // 获取翅膀重铸界面的重铸物品
    public static void getRecastGoods(Graphics g, LHMainPanel wingMainPanel, int x, int y) {
        Goodstable goodstable = UserMessUntil.getgoodstable(new BigDecimal(8892));
        if (goodstable == null) {
            // return;
        } else {
            g.drawImage(imgpathAdaptive(goodstable.getSkin(), 49, 49).getImage(), x, y, 49, 49, null);
        }
        for (int i = 0; i < Goodslist.length; i++) {
            if (Goodslist[i] == null) {
                continue;
            }
            if (Goodslist[i].getType() == 8892) {
                wingMainPanel.setChosegoods(Goodslist[i]);
                // g.drawImage(imgpathAdaptive(wingMainPanel.getChosegoods().getSkin(),
                // 58, 56).getImage(), x, y, 58, 56, null);
                g.setColor(Color.red);
                g.drawString(Goodslist[i].getUsetime().toString(), x + 2, y + 12);
                return;
            }
        }
        g.setColor(Color.red);
        g.drawString("0", x + 2, y + 12);
    }


    // 获取翅膀炼化界面的炼化物品
    public static void getRefiningGoods(Graphics g, WingMainPanel wingMainPanel, int x, int y) {
        Goodstable goodstable = UserMessUntil.getgoodstable(new BigDecimal(8893));
        if (goodstable == null) {
            // return;
        } else {
            g.drawImage(imgpathAdaptive(goodstable.getSkin(), 58, 56).getImage(), x, y, 58, 56, null);
        }
        for (int i = 0; i < Goodslist.length; i++) {
            if (Goodslist[i] == null) {
                continue;
            }
            if (Goodslist[i].getType() == 8893) {
                wingMainPanel.setChosegoods(Goodslist[i]);
                // g.drawImage(imgpathAdaptive(wingMainPanel.getChosegoods().getSkin(),
                // 58, 56).getImage(), x, y, 58, 56, null);
                g.setColor(Color.red);
                g.drawString(Goodslist[i].getUsetime().toString(), x + 2, y + 12);
                return;
            }
        }
        g.setColor(Color.red);
        g.drawString("0", x + 2, y + 12);
    }
    // 获取翅膀炼化界面的炼化物品
    public static void getRefiningGoods(Graphics g, LHMainPanel wingMainPanel, int x, int y) {
        Goodstable goodstable = UserMessUntil.getgoodstable(new BigDecimal(7010));
        if (goodstable == null) {
            // return;
        } else {
            g.drawImage(imgpathAdaptive(goodstable.getSkin(), 58, 56).getImage(), x, y, 58, 56, null);
        }
        for (int i = 0; i < Goodslist.length; i++) {
            if (Goodslist[i] == null) {
                continue;
            }
            if (Goodslist[i].getType() == 7010) {
                wingMainPanel.setChosegoods(Goodslist[i]);
                // g.drawImage(imgpathAdaptive(wingMainPanel.getChosegoods().getSkin(),
                // 58, 56).getImage(), x, y, 58, 56, null);
                g.setColor(Color.red);
                g.drawString(Goodslist[i].getUsetime().toString(), x + 2, y + 12);
                return;
            }
        }
        g.setColor(Color.red);
        g.drawString("0", x + 2, y + 12);
    }
    // 翅膀图片展示
    public static void drawWingImg(Graphics g, WingMainPanel wingMainPanel, int x, int y) {
        for (int i = 25 * (wingMainPanel.getPageNumber() - 1); i < wingGoodsList.size(); i++) {
            ImageIcon imgpathAdaptive = imgpathAdaptive(wingGoodsList.get(i).getSkin(), 49, 49);
            g.drawImage(imgpathAdaptive.getImage(), x + i % 25 % 5 * 51, y + i % 25 / 5 * 51, 49, 49, null);
            if (i >= 25 * wingMainPanel.getPageNumber() - 1) {
                return;
            }
        }
    }

    /**
     * 画出召唤兽装备的材料物品
     *
     * @param g
     * @param x
     * @param y
     */
    public static void drawSummonGoods(Graphics g, int x, int y) {
        int num = 0;
        for (int i = 0; i < Goodslist.length; i++) {
            if (Goodslist[i] == null) {
                continue;
            }
            if (!Goodtype.isSummonEquip(Goodslist[i].getType()) && !Goodtype.isSummonGoods(Goodslist[i].getType())) {
                continue;
            }

            g.drawImage(imgpathAdaptive(Goodslist[i].getSkin(), 50, 50).getImage(), x + num % 6 * 51, y + num / 6 * 51,
                    50, 50, null);

            if (Goodtype.isSummonGoods(Goodslist[i].getType())) {
                g.setColor(Color.red);
                g.drawString(Goodslist[i].getUsetime() + "", x + 4 + num % 6 * 51, y + 10 + num / 6 * 51);
            }
            num++;

            if (num >= 12) {
                return;
            }
        }
    }


    //整理当铺
    public static void zhengli() {
        int len = Goodslist.length;
        if (len < 48) {
            ZhuFrame.getZhuJpanel().addPrompt("#G道具栏整理只会整理第二页及之后的道具栏，你没有可以整理的道具栏");
        } else {
            for(int i = 24; i < len - 1; ++i) {
                int tem = i;

                for(int j = i + 1; j < len; ++j) {
                    if (Goodslist[j] != null && (Goodslist[tem] == null || Goodslist[j].getType() < Goodslist[tem].getType())) {
                        tem = j;
                    }
                }

                Goodstable temp1 = Goodslist[i];
                Goodslist[i] = Goodslist[tem];
                Goodslist[tem] = temp1;
            }

            PageNumberChange(Pagenumber);
        }
    }
    /**
     * 获取当前召唤兽材料
     *
     * @param type
     * @return goodstable
     */
    public static Goodstable getSummonGoods(int type) {
        int num = 0;
        for (int i = 0; i < Goodslist.length; i++) {
            if (Goodslist[i] == null) {
                continue;
            }
            if (!Goodtype.isSummonEquip(Goodslist[i].getType()) && !Goodtype.isSummonGoods(Goodslist[i].getType())) {
                continue;
            }
            if (type == num) {
                return Goodslist[i];
            }
            num++;
        }
        return null;
    }

    /** 获取并展示星卡图片 */
    public static void drawStarCardImg(Graphics g, int x, int y) {
        for (int i = 0; i < starCardList.size(); i++) {
            Goodstable goodstable = starCardList.get(i);
            g.drawImage(imgpathAdaptive(goodstable.getSkin(), 50, 50).getImage(), x + i % 4 * 51, y + i / 4 * 51, 50,
                    50, null);
            if (goodstable.getStatus() == 1) {
                g.drawImage(CutButtonImage.getImage("inkImg/old/lingbao/msg/lf_g.png", 26, 26).getImage(),
                        x + 24 + i % 4 * 51, y + i / 4 * 51, 26, 26, null);
            }
            if (goodstable.getGoodlock() == 1) {
                g.drawImage(lockimg.getImage(), x + i % 4 * 51, y + i / 4 * 51, 10, 12, null);
            }
            if (i >= 23) {
                return;
            }
        }
    }

    /** 获取并展示星卡图片 */
    public static void drawStarCardImg(Graphics g, int x, int y, ArrayList<BigDecimal> num) {
        for (int i = 0; i < starCardList.size(); i++) {
            Goodstable goodstable = starCardList.get(i);
            g.drawImage(imgpathAdaptive(goodstable.getSkin(), 50, 50).getImage(), x + i % 6 * 51, y + i / 6 * 51, 50,
                    50, null);
            if (num.contains(goodstable.getRgid())) {
                g.drawImage(CutButtonImage.getImage("inkImg/old/lingbao/msg/lf_g.png", 26, 26).getImage(),
                        x + 24 + i % 6 * 51, y + i / 6 * 51, 26, 26, null);
            }
            if (goodstable.getGoodlock() == 1) {
                g.drawImage(lockimg.getImage(), x + i % 6 * 51, y + i / 6 * 51, 10, 12, null);
            }
            if (i >= 23) {
                return;
            }
        }
    }

    /** 获取指定星卡物品 */
    public static Goodstable getStarCardGoods(int type) {
        for (int i = 0; i < starCardList.size(); i++) {
            if (type == i) {
                return starCardList.get(i);
            }
        }
        return null;
    }

    /** 获取星卡培养材料图片 */
    public static void drawStarCardCultivateMaterialImg(Graphics g, long type, int x, int y) {
        int num = 0;
        for (int i = 0; i < Goodslist.length; i++) {
            Goodstable goodstable = Goodslist[i];
            if (goodstable == null) {
                continue;
            }
            if (goodstable.getType() != type) {
                continue;
            }
            g.drawImage(imgpathAdaptive(goodstable.getSkin(), 50, 50).getImage(), x + num % 6 * 51, y + num / 6 * 51,
                    50, 50, null);
            g.setColor(Color.red);
            g.drawString(Goodslist[i].getUsetime() + "", x + 2 + num % 6 * 51, y + 11 + num / 6 * 51);
            num++;
            if (num >= 12) {
                return;
            }
        }
    }

    /** 获取星卡培养材料 */
    public static Goodstable getStarCardCultivateMaterialGoods(long type, int nowNum) {
        int num = 0;
        for (int i = 0; i < Goodslist.length; i++) {
            Goodstable goodstable = Goodslist[i];
            if (goodstable == null) {
                continue;
            }
            if (goodstable.getType() != type) {
                continue;
            }
            if (nowNum == num) {
                return goodstable;
            }
            num++;
        }
        return null;
    }

    /** 斗转星移面板 */
    public static void drawStarArray(Graphics g, int x, int y) {
        for (int i = 0; i < starCardList.size(); i++) {
            Goodstable goodstable = starCardList.get(i);
            g.drawImage(imgpathAdaptive(goodstable.getSkin(), 50, 50).getImage(), x + i * 51, y, 50, 50, null);
            if (i >= 8) {
                return;
            }
        }
    }

    public static Goodstable getStarArray(int type) {
        for (int i = 0; i < starCardList.size(); i++) {
            if (type == i) {
                return starCardList.get(i);
            }
            if (i >= 8) {
                return null;
            }
        }
        return null;
    }

    /** 画伙伴物品 */
    public static void drawPalGoods(int x, int y, Graphics g) {
        int num = 0;
        for (int i = 0; i < Goodslist.length; i++) {
            if (Goodslist[i] == null) {
                continue;
            }
            // 7500-7550
            if (Goodtype.isPalGoods(Goodslist[i].getType())) {
                g.drawImage(imgpath(Goodslist[i].getSkin()).getImage(), x + num % 3 * 39, y + num / 3 * 40, 38, 39,
                        null);
                if (!Goodtype.isPalEquip(Goodslist[i].getType())) {
                    g.setColor(Color.red);
                    g.drawString(Goodslist[i].getUsetime() + "", x + num % 3 * 39, y + 11 + num / 3 * 40);
                }

                num++;
                if (num >= 24) {
                    return;
                }
            }
        }
    }

    /**
     * 获取对应的伙伴物品
     *
     * @param type
     * @return
     */
    public static Goodstable getPalGoods(int type) {
        int num = 0;
        for (int i = 0; i < Goodslist.length; i++) {
            if (Goodslist[i] == null) {
                continue;
            }
            // 7500-7550
            if (Goodtype.isPalGoods(Goodslist[i].getType())) {
                if (num == type) {
                    return Goodslist[i];
                }
                num++;
                if (num >= 24) {
                    return null;
                }
            }
        }
        return null;
    }

    public static Goodstable[] getGoodslist() {
        return Goodslist;
    }

    public static Goodstable[] getChoseGoodsList() {
        return choseGoodsList;
    }

    public static List<Goodstable> getWingGoodsList() {
        return wingGoodsList;
    }

    public static Goodstable[] getChose1() {
        return choseGoodsList;
    }

    public static void setWingGoodsList(List<Goodstable> wingGoodsList) {
        GoodsListFromServerUntil.wingGoodsList = wingGoodsList;
    }

    public static List<Goodstable> getStarCardList() {
        return starCardList;
    }

    public static void setStarCardList(List<Goodstable> starCardList) {
        GoodsListFromServerUntil.starCardList = starCardList;
    }

    public static Goodstable chaxunsNew(int goodid) {
        for (int j = 0; j < Goodslist.length; j++) {
            if (Goodslist[j] != null) {
                if (Goodslist[j].getGoodsid().intValue() == goodid) {
                    return Goodslist[j];
                }
            }
        }
        return null;
    }
    public static Goodstable getgood(int goodid) {

        for (int i = 0; i < Goodslist.length; i++) {
            if (Goodslist[i] == null)
                continue;
            if (Goodslist[i].getGoodsid().intValue() != goodid)
                continue;
            return Goodslist[i];
        }
        return null;
    }
    /** 查询物品类型 和数量判断是否足够 */
    public static boolean istype(int type, int sum) {
        int sysum = 0;
        for (int i = 0; i < Goodslist.length; i++) {
            if (Goodslist[i] == null)
                continue;
            if (Goodslist[i].getType().intValue() != type)
                continue;
            sysum += Goodslist[i].getUsetime();
            if (sysum >= sum)
                return true;
        }
        return false;
    }
    public static void Deletebiaoid11(final BigDecimal biaoid) {
        int i = 0;
        while (i < GoodsListFromServerUntil.Goodslist.length) {
            if (GoodsListFromServerUntil.Goodslist[i] != null && GoodsListFromServerUntil.Goodslist[i].getRgid().intValue() == biaoid.intValue() && (GoodsListFromServerUntil.Goodslist[i].getUsetime().intValue() <= 0 || GoodsListFromServerUntil.Goodslist[i].getStatus().intValue() != 0)) {
                GoodsListFromServerUntil.Goodslist[i] = null;
                PageNumberChange(GoodsListFromServerUntil.Pagenumber);
                return;
            }
            else {
                ++i;
            }
        }
    }
}
